//
//  XiangceViewController.m
//  LOU
//
//  Created by apple on 15/11/9.
//  Copyright © 2015年 UNOHACHA. All rights reserved.
//

#import "XiangceViewController.h"
#import "BaseView.h"
#import "Size.h"
@interface XiangceViewController ()<UIScrollViewAccessibilityDelegate>

@property (nonatomic,retain) BaseView *baseview;
@property (nonatomic,retain) UIScrollView *scroll;
@property (nonatomic, retain) UIScrollView *scrollview;
@property (nonatomic,retain) NSArray *arr;
@property (nonatomic,retain) UILabel *label;
@end

@implementation XiangceViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    
    self.baseview = [[BaseView alloc] initWithFrame:self.view.frame];
    [self.view addSubview:self.baseview];
    [self.baseview addTarget:self selector:@selector(fan)];
    self.baseview.backgroundColor = [UIColor blackColor];
    
    self.scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 210*Height, WindowWidth, 240*Height)];
    [self.view addSubview:self.scroll];
    self.scroll.backgroundColor = [UIColor whiteColor];
    self.scroll.contentSize = CGSizeMake(WindowWidth*10, 0);
    self.scroll.pagingEnabled = YES;
    //self.scroll.showsHorizontalScrollIndicator = YES;
    self.scroll.contentOffset = CGPointMake(0, 0);
    self.scroll.delegate = self;
    self.scroll.tag = 300;
    
    for (int i = 0; i < 10; i++) {
        self.scrollview = [[UIScrollView alloc] initWithFrame:CGRectMake(WindowWidth*i, 0, WindowWidth,240*Height)];
        self.scrollview.contentSize = CGSizeMake(WindowWidth, 0);
        _scrollview.scrollEnabled = YES;
        [_scroll addSubview:_scrollview];
        //_scrollview.pagingEnabled = YES;
        _scrollview.maximumZoomScale = 2.5;
        _scrollview.minimumZoomScale = 0.5;
        _scrollview.delegate = self;
        BaseView *view5 = [[BaseView alloc] initWithFrame:CGRectMake(0, 0, WindowWidth, 240*Height)];
        //view5.center = self.view.center;
        [self.scrollview addSubview:view5];
        view5.imgaeview.image = [UIImage imageNamed:[NSString stringWithFormat:@"shouye%d.jpg",i+1]];
        [view5 addTarget:self selector:@selector(fan)];
    }
    
    self.label = [[UILabel alloc] initWithFrame:CGRectMake(275/2*Width, 470*Height, 100*Width, 35)];
    [self.baseview addSubview:self.label];
    self.label.textColor = [UIColor whiteColor];
    self.label.textAlignment = 1;
    self.label.text = [NSString stringWithFormat:@"%2.0f / %2.0f",self.scroll.contentOffset.x/WindowWidth+1,self.scroll.contentSize.width/WindowWidth];
}
-(void)fan{
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
}
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    if (scrollView.tag == 300) {
        NSLog(@"999");
        self.label.text = [NSString stringWithFormat:@"%2.0f / %2.0f",self.scroll.contentOffset.x/WindowWidth+1,self.scroll.contentSize.width/WindowWidth];
        //self.scrollview.zoomScale = 1.0;
        
    }
}
-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
    NSLog(@"==========");
    
    return [scrollView.subviews firstObject];
}

- (void)scrollViewDidZoom:(UIScrollView *)scrollView
{
    NSLog(@"123");
    
}

@end
